﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMS.HelperClasses;
using WHMS.EntityClasses;
using WHMS.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WMS
{
	public partial class RoleForm : Form
	{
		public RoleForm()
		{
			InitializeComponent();

			var dataForm = new DataMngrFormBase<RoleEntity>(_roles, dataGridView1, bindingSource1, SaveBtn, SaveResult, DeleteResult);
			dataForm.SetMNInfo(typeof(UserRoleEntity), AllUsersList, AssignedUsersList, UserFields.Id, UserFields.Name, UserRoleFields.UserId, UserRoleFields.RoleId);
			dataForm.SetMNAssociationButtons(AssignSelectedBtn, AssignAllBtn, UnAssignSelectedBtn, UnAssignAllBtn, SaveDetailsBtn);
			dataForm.MNSaved += new DataMngrFormBase<RoleEntity>.RaiseMNSaved(dataForm_MNSaved);
			dataForm.SetMandatoryFields(new List<int>() {0, 1 });

			var uniqueFields = new Dictionary<int, EntityField2>();
			uniqueFields.Add(0, RoleFields.Code);
			uniqueFields.Add(1, RoleFields.Name);
			dataForm.SetUniqueFields(uniqueFields, RoleFields.Id);
		}
		
		void dataForm_MNSaved(int selectedId)
		{
			MessageBox.Show("تم الحفظ بنجاح.");
		}
	}
}
